package cn.wolfcode.trip.base.domain;
import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
public class SystemNotice extends BaseDomain {

    //状态
    public static final int STATE_READ = 1;//未读
    public static final int STATE_UNREAD = 2;//已读

    private User user;//被通知方

    private String content;//通知内容

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date createTime;//创建时间

    private Integer isnew;//是否已读,1是未读,2是已读

    public String getJson(){
        Map<String,Object> map=new HashMap();
        map.put("id",id);
        map.put("content",content);
        if (user!=null) {
            map.put("userId",user.getId());
            map.put("phone",user.getPhone());
        }
        return JSONUtil.toJSONString(map);
    }

}

